package demo1;

public class Person implements Cloneable{   //实现空接口的类，代表可以拷贝
              String name;
              int age ;

              Money money1 = new Money(10);

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person tmp = (Person) super.clone();    //谁调用了super方法，不需要this指定对象。
        tmp.money1 = (Money) this.money1.clone();
        return tmp;



    }
}
